import promise from 'redux-promise'
import logger from 'redux-logger'
import checker from '../../middlewares/checker'
import { applyMiddleware, createStore, combineReducers } from 'redux'
import reducers from '../../reducers/auth'
import { browserHistory } from 'react-router'

export default () => {
	const createStoreWithMiddleware = applyMiddleware(
		promise,
		checker
		//logger
	)(createStore)

	const store = createStoreWithMiddleware(reducers)

	if (module.hot) {
		module.hot.accept('../../reducers/auth', () => {
			const nextReducer = require('../../reducers/auth')
			store.replaceReducer(nextReducer)
		})
	}

	return store
}
